package com.android.lgc.android_mvp.utils;

import android.content.Context;

/**
 * @author $
 * @fileName TestManager
 * @date2021/5/26 11:39
 * @describe TODO
 * @desc 测试 数据类
 */
public class TestManager {
    private Context context;

    private static TestManager instance;

    //会出现内存泄露的写法
//    public static TestManager getInstance(Context context){
//        if(instance==null){
//            instance=new TestManager(context);
//        }
//        return instance;
//    };

    //正确的写法是
    public static TestManager getInstanceSafe(Context context) {
        if (instance == null) {
            instance = new TestManager(context.getApplicationContext());
        }
        return instance;
    }

    private TestManager(Context context){
        this.context=context;
    };


}
